defmodule PlayTest do
  use ExUnit.Case
  doctest Play

  def mul_s(s, i) when i <= 0, do: s
  def mul_s(s, i), do: mul_s(" " <> s, i - 1)

  def reducer(x, acc, i) when is_binary(x), do: [mul_s(x, i)| acc]
  def reducer(x, acc, i) when is_tuple(x), do: trav(x, acc, i + 1)
  def reducer(_, acc), do: acc

  def output(s_arr) when is_list(s_arr), do: Enum.each(s_arr, fn x -> IO.puts x end)
  def output(s_arr), do: IO.puts "invalid s_arr: #{s_arr}"

  def trav(x, acc_origin, i) do
    x |> Tuple.to_list |> Enum.reduce(acc_origin, fn(x, acc) -> reducer(x, acc, i) end)
  end
  def trav(x), do: x |> trav([], 0) |> Enum.reverse |> output

  test "greets the world" do
    trav {"See Spot.", {"See Spot.", "See Spot."}}
  end

  test "2" do
    
  end
end
